"use strict";

const moleculerMail = require("moleculer-mail");

module.exports = {
	// name: "mail2",
	version:1,
	mixins: [moleculerMail],
	/**
	 * Settings
	 */
	settings: {
		from: "zhjtdyx@126.com",
		transport: {
			host: "smtp.126.com",
			port: 25,
			auth: {
				user: "zhjtdyx@126.com",
				pass: "DNWCMXWIJAUOGPFF"
			}
		},
	},

	/**
	 * Dependencies
	 */
	dependencies: [],

	/**
	 * Actions
	 */
	actions: {
		/**
		 * The broker calls the local action directly
		 */
		sendMail:{
			rest:{
				method:'GET',
				path:'/send2'
			},
			async handler(ctx) {
				return  await  this.broker.call("v1.mail.send", {
					to: "zhoujt@head-aerospace.com",
					cc: "headcloud@head-aerospace.com",
					subject: "Hello Friends!",
					text: "This is a text only message!"
				}).then(console.log);
			}
		},

	},

	/**
	 * Events
	 */
	events: {

	},

	/**
	 * Methods
	 */
	methods: {

	},

	/**
	 * Service created lifecycle event handler
	 */
	created() {

	},

	/**
	 * Service started lifecycle event handler
	 */
	async started() {

	},

	/**
	 * Service stopped lifecycle event handler
	 */
	async stopped() {

	}
};
